Code
library(dplyr)
library(tidyr)
library(vegan)
library(ggplot2)
library(targets)
library(ggrepel)
theme_set(theme_light())This document contains all data analyses presented in the main article as well as supplementary materials.
The analysis was organized using the make-line pipeline tool provided by targets (Landau 2021). You will find raw data as well as all functions used in the pipeline in the project’s research compendium created with the rcompendium package (Casajus N. 2022).
You can take a look at the pipeline in order to understand some steps (mostly related to tidying data)
library(dplyr)
library(tidyr)
library(vegan)
library(ggplot2)
library(targets)
library(ggrepel)
theme_set(theme_light())Take a look at the structure of the final complexity dataset
tar_load(comp)
knitr::kable(head(comp))
| Mini | Site | Point | Sample | Branching_density | Broken_density | D_bin | D_gray | L | I | S | Total_Density | Dry_weight | Sphericity | DR1 | DR2 | DR3 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| MBE_1 | Belle-ile | Belle-ile 1 | 1 | 5.8 | 0.0 | 1.1231 | 2.6562 | 12.85333 | 9.143333 | 8.303333 | 181696 | 183.61 | 0.8371338 | 0.6460062 | 0.8153846 | 0.7113589 |
| MBE_1 | Belle-ile | Belle-ile 1 | 2 | 1.0 | 0.0 | 1.0654 | 2.6463 | 16.07667 | 7.883333 | 5.393333 | 181696 | 183.61 | 0.6122605 | 0.3354758 | 0.7669267 | 0.4903587 |
| MBE_1 | Belle-ile | Belle-ile 1 | 3 | 3.0 | 0.2 | 1.0722 | 2.6450 | 15.30000 | 8.103333 | 7.190000 | 181696 | 183.61 | 0.7470808 | 0.4699346 | 0.8873818 | 0.5296296 |
| MBE_1 | Belle-ile | Belle-ile 1 | 4 | 4.8 | 0.4 | 1.1078 | 2.6492 | 12.91667 | 8.476667 | 6.203333 | 181696 | 183.61 | 0.7057078 | 0.4802581 | 0.6613704 | 0.6562581 |
| MBE_1 | Belle-ile | Belle-ile 1 | 5 | 4.2 | 0.0 | 1.1305 | 2.7019 | 24.54667 | 14.523333 | 8.970000 | 181696 | 183.61 | 0.6088477 | 0.3654264 | 0.6434838 | 0.5916621 |
| MBE_1 | Belle-ile | Belle-ile 1 | 6 | 3.0 | 0.4 | 1.1198 | 2.6641 | 16.35667 | 9.416667 | 6.783333 | 181696 | 183.61 | 0.6684949 | 0.4147137 | 0.7249304 | 0.5757082 |
Most variables are not normally distributed so we apply a box-cox (Box and Cox 1964) transformation and check correlations between the transformed variables
tar_read(pairscomp)Let’s check it without removing highly correlated variables
tar_load(pcatotal)
tar_read(sptot)We had up to 6 relevant axes to look at, but we know we have several highly correlated variables
tar_load(pcatot)
plot(pcatot)tar_load(pcatotsel)
tar_read(sptotsel)Let’s check the biplots of the selected variables
tar_load(pcasel)
plot(pcasel)tar_read(spmedsel)Let’s check the biplots of the selected variables
tar_load(pcamed)
plot(pcamed)tar_load(corcomp)
plot(corcomp[[1]])`geom_smooth()` using formula = 'y ~ x'
plot(corcomp[[2]])`geom_smooth()` using formula = 'y ~ x'
tar_read(cortestcomp1)
tar_read(cortestcomp2)
Pearson's product-moment correlation
data: med_sel2$PC1_c and med_sel2$PC1_score
t = -12.623, df = 28, p-value = 4.471e-13
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.9626648 -0.8416107
sample estimates:
cor
-0.9222483
Pearson's product-moment correlation
data: med_sel2$PC2_c and med_sel2$PC2_score
t = -14.294, df = 28, p-value = 2.165e-14
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.9702598 -0.8722282
sample estimates:
cor
-0.9378045
tar_load(faunadata)
knitr::kable(head(faunadata))
| Point | Site | Replicate | Method | Habitat | Year | Season | Date | Species | Abundance |
|---|---|---|---|---|---|---|---|---|---|
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Abludomelita gladiosa | 1 |
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Abra alba | 1 |
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Ampharete spp. | 1 |
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Amphipholis squamata | 2 |
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Anapagurus hyndmanni | 1 |
| Belle-ile 1 | Belle-ile | 1 | Grab | Maerl | 2007 | Spring | 2007-03-11 00:00:00 | Aonides oxycephala | 3 |
samplespoint <- faunadata %>%
mutate(Date=as.factor(format.Date(faunadata$Date,"%Y"))) %>%
distinct(Site, Year, Point, Replicate) %>%
group_by(Site, Year, Point) %>%
mutate(Year = as.factor(Year)) %>%
summarise(count = n()) %>%
ungroup() %>%
mutate(State = factor(case_when(count==3 ~ "Good", count < 3 ~ "Sample(s) missing", count > 3 ~ "Too many samples")))
ggplot(samplespoint, aes(x=Year,y=Point,fill=State)) +
geom_tile(alpha=0.5) +
scale_fill_manual(values=c("palegreen3","lightblue", "indianred")) +
geom_text(aes(label=count)) +
theme(text=element_text(size =15), axis.text.x = element_text(angle = 90, size = 15), legend.position = "bottom")Empty cells show points where no samples were collected at a given date due to field constraints.
# Total richness
tar_load(faunaclass)
total_rich <- nrow(faunaclass %>%
distinct(., Species)) #725 species
# Total richness by sediment position
epi_rich <- nrow(faunaclass %>%
filter(Position == "Epifauna") %>%
distinct(., Species)) #341 epifaunal species
inf_rich <- nrow(faunaclass %>%
filter(Position == "Infauna") %>%
distinct(., Species)) #266 infaunal species
int_rich <- nrow(faunaclass %>%
filter(Position == "Interstice") %>%
distinct(., Species)) #118 interstitial speciesThere are 725 species in total, 341 being epifaunal, 266 being infaunal, and 118 interstitial.
tar_read(relab_phy)
tar_read(relab_ord) p.s.: it is normal to have NAs for some orders as higher classification for some of the species is ambiguous or unknown.
tar_read(relab_arth)
tar_read(relab_ann)
tar_read(relab_mol)